<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib tagdir="/WEB-INF/tags/busterminal" prefix="bt"%>
<%@taglib uri="/WEB-INF/tags/tlds/Functions.tld" prefix="f"%>

<table class="table table-striped table-bordered table-condensed">
    <caption>Bus model list</caption>
    <thead>
        <tr>
            <th align="center">Model name</th>
            <th align="center">Vehicle type</th>
        </tr>
    </thead>
    <tbody>
        <c:set var="user" scope="session" value="${userAuth}" />
        <c:forEach var="busMod" items="${busModelList}">
            <tr>                
                <td><c:out value="${busMod.getModelName()}" /></td>
                <td><c:out value="${busMod.getVehicleType()}" /></td>
                
                <c:if test="${f:isActionAllowed('bus.model.edit', user.getRole())}">
                    <c:url var="editURL" value="MainServlet">
                        <c:param name="action" value="bus.model.edit" />
                        <c:param name="id" value="${busMod.getId()}" />
                    </c:url>
                    <td nowrap width="48"><a class="btn btn-mini" href="${editURL}" id="show-edit-form" data-toggle="tab"><i class="icon-pencil icon-white"></i>&nbsp;Edit</a></td>
                </c:if>

                <c:if test="${f:isActionAllowed('bus.model.delete', user.getRole())}">
                    <c:url var="deleteURL" value="MainServlet">
                        <c:param name="action" value="bus.model.delete" />
                        <c:param name="id" value="${busMod.getId()}" />
                    </c:url>
                    <td nowrap width="62"><a class="btn btn-mini" id="show-delete-dialog" data-target="#delete-modal-window" data-toggle="modal" data-link="${deleteURL}" data-name="${busMod.getModelName()}; ${busMod.getVehicleType()}"><i class="icon-trash icon-white"></i>&nbsp;Delete</a></td>
                </c:if>    
            </tr>
        </c:forEach>
        <c:if test="${f:isActionAllowed('bus.model.create', user.getRole())}">
            <tr>
                <td colspan="5">
                    <a class="btn btn-mini" href="MainServlet?action=bus.model.create" id="show-create-form" data-toggle="tab"><i class="icon-plus icon-white"></i>&nbsp;New bus model</a>
                </td>
            </tr>
        </c:if>
    </tbody>
</table>
<bt:DeleteDialog entity="bus model" />